<?php
/**
 * 描述：会员管理中心-修改公司资料。
 * @final
 */
final class Exec_MC_Account_Info extends Exec_MC_Master
{   
    public function Get()
    {
        #绑定变量
        View::Assign
        (
            'Model',array
            (
                'BUSINESS'=>DAO_BusinessModel::BUSINESS_VALUE,
                'PRODUCTION'=>DAO_BusinessModel::PRODUCTION_VALUE,
                'SERVICE'=>DAO_BusinessModel::SERVICE_VALUE,
                'WHOLESALE'=>DAO_BusinessModel::WHOLESALE_VALUE
            )
        );

        #绑定数据-主营行业
        $data=DB::GetRows('select * from trade where Identifying_Parent is NULL order by ID asc');
        View::Assign('Trade_Class',$data);

        #绑定数据
        $data=DB::PGetRows('select * from account where Username=?',array
        (
            Account::Session('Username')
        ));
        if($data)
        {
            $data[0]['LogoLocation']=Config::PATH_RELATIVE_ATTACHMENT_LOGO.'/'.$data[0]['Logo'];
            $tmp=NULL;
            {
                if($data[0]['Trade_Subclass']){
                    $tmp=DB::GetRows('select * from trade where Identifying in('.Filter::Mysql_Contact($data[0]['Trade_Subclass']).') order by ID asc');             
                }
            }
            View::Assign('Trade_Result',$tmp);
            View::Assign('Data',$data[0]);
            $this->MasterPage_Display(View::Fetch('mc/account/info.tpl'));
        }
        else
        {
            echo '找不到该用户';
            return;
        }
    }

    public function Post()
    {
        #获取数据
        $data=array
        (
            'CompanyName'=>Functions::FormArgs('CompanyName'),              //公司名称
            'Model'=>Functions::FormArgs('Model'),                          //经营模式
            'RegisterdCapital'=>Functions::FormArgs('RegisterdCapital'),    //注册时间
            'EstablishedTime'=>Functions::FormArgs('EstablishedTime'),      //成立时间
            'Trade'=>Functions::FormArgs('Trade'),                          //主营行业
            'Trade_Class'=>Functions::FormArgs('Trade_Class_Value'),
            'Trade_Subclass'=>Functions::FormArgs('Trade_Subclass_Value'),
            'Product'=>Functions::FormArgs('Product'),                      //主营产品
            'Partner'=>Functions::FormArgs('Partner'),                      //合作伙伴
            'Province'=>Functions::FormArgs('Province'),                    //省
            'City'=>@$_POST['City'],                                        //城市
            'Address'=>Functions::FormArgs('Address'),                      //地址
            'Intro'=>strip_tags(Functions::FormArgs('Intro'),60000,FALSE),                          //公司简介
            'Linkman'=>Functions::FormArgs('Linkman'),
            'Sex'=>Functions::FormArgs('Sex'),
            'Department'=>Functions::FormArgs('Department'),
            'Position'=>Functions::FormArgs('Position'),
            'URL'=>Functions::FormArgs('URL'),
            'Phone'=>Functions::FormArgs('Phone'),
            'Fax'=>Functions::FormArgs('Fax'),
            'MSISDN'=>Functions::FormArgs('MSISDN'),
            'QQ'=>Functions::FormArgs('QQ'),
            'MSN'=>Functions::FormArgs('MSN')
        );

        #图片处理
        $result=Upload::Probe($_FILES['Logo'],Config::UPLOAD_ATTACHMENT_SIZE_IMAGE,Config::UPLOAD_ATTACHMENT_EXT_IMAGE,Config::PATH_UPLOAD_ATTACHMENT_TEMP);
        $FileName=NULL;
        if($result['error']!=UPLOAD_ERR_NO_FILE)    //如果上传了文件
        {
            switch($result['error'])
            {
                case UPLOAD_ERR_OK:
                    $FileName=Upload::Execute($_FILES['Logo'],Config::PATH_UPLOAD_ATTACHMENT_TEMP);
                    @unlink(Config::PATH_UPLOAD_ATTACHMENT_TEMP.'/'.Functions::FormArgs('LogoValue'));
                break;
                case Upload::UPLOAD_ERR_CUSTOM_EXT:
                    echo 'Logo:EXT:Logo图片格式不正确，只能是：'.join(',',Upload::$UPLOAD_EXT_IMAGE).'。';
                    return;
                break;
                case Upload::UPLOAD_ERR_CUSTOM_SIZE:
                    echo 'Logo:Size:Logo图片大小超过了限制，不能超过：'.Functions::SizeFormat(Config::UPLOAD_ATTACHMENT_SIZE_IMAGE).'。';
                    return;
                break;
                default :
                    echo 'Logo:Fail';   //Logo上传失败
                    return;
            }
        }
        if($FileName){
            $data['Logo']=$FileName;
        }

        #更新数据
        DB::UpdateRowByField('account','Username:'.Account::Session('Username'),$data);
        echo 'Success';
    }
}
?>